/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.modules.app.version.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.CacheNames;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.modules.app.version.entity.AppUpgrade;
import org.springblade.modules.app.version.service.IAppUpgradeService;
import org.springblade.modules.desk.entity.Notice;
import org.springblade.modules.desk.service.INoticeService;
import org.springblade.modules.desk.vo.NoticeVO;
import org.springblade.modules.desk.wrapper.NoticeWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制器
 *
 * @author Chill
 */
@RestController
@RequestMapping("/")
@AllArgsConstructor
@ApiSort(2)
@Api(value = "版本升级", tags = "版本升级")
public class UpgradeController extends BladeController implements CacheNames {

	private IAppUpgradeService appUpgradeService;

	/**
	 * 详情
	 */
	@GetMapping("/upgrade.json")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入notice")
	public R<AppUpgrade> upgrade() {
		AppUpgrade appUpgrade = new AppUpgrade();
		appUpgrade.setEnable(true);
		QueryWrapper<AppUpgrade> queryWrapper = Condition.getQueryWrapper(appUpgrade);
		queryWrapper.last("LIMIT 1");
		AppUpgrade detail = appUpgradeService.getOne(queryWrapper);
		return R.data(detail);
	}

}
